package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type appconf struct {
	Mysql
	Redis
	Es
	QiNiuYun
}

type Mysql struct {
	User     string
	Password string
	Hort     string
	Post     int
	DB       string
}

type Redis struct {
	Addr     string
	Password string
	Data     int
}

type Es struct {
	Addr string
}

type QiNiuYun struct {
	AK string
	SK string
}

var Conf appconf

func Init() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		fmt.Println("配置文件下载失败")
	}
	fmt.Println("viper初始化成功")
}
